package com.heima.search.controller.v1;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.search.dtos.UserSearchDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.heima.search.service.IApUserSearchService;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * APP用户搜索信息表 前端控制器
 * </p>
 *
 * @author heima
 * @since 2021-03-27
 */
@RestController
@RequestMapping("/api/v1/history")
@Api(tags = "APP用户搜索信息表接口")
@CrossOrigin
public class ApUserSearchController{

    @Autowired
    private IApUserSearchService apUserSearchService;

    /**
     * 查询搜索记录列表
     */
    @PostMapping("/load")
    public ResponseResult<Set<String>> loadSearchWords(@RequestBody UserSearchDto dto){
        Set<String> set = apUserSearchService.loadSearchWords(dto);
        return ResponseResult.ok(set);
    }

    /**
     * 删除搜索记录
     */
    @PostMapping("/del")
    public ResponseResult delSearchWords(@RequestBody UserSearchDto dto){
       apUserSearchService.delSearchWords(dto);
        return ResponseResult.ok();
    }

}
